package com.tiancheng.trade.authserver.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.tiancheng.trade.authserver.entity.AuthPermission;
import com.tiancheng.trade.authserver.entity.AuthRole;
import com.tiancheng.trade.authserver.entity.AuthRoleMapPermission;

import java.util.List;
import java.util.Map;
import java.util.Set;

public interface IAuthRoleMapPermissionService extends IService<AuthRoleMapPermission> {
    String rMPIdLockKey = "auth:roleMapPermission:id:lock:";
    String rMPRoleIdPermissionIdLockKey = "auth:roleMapPermission:roleIdPermissionId:lock:";

    /**
     * 删除角色拥有权限
     */
    void removeRolePermission(Long roleId);

    /**
     * 根据权限id删除映射
     */
    void removeByPermissionId(Long permissionId);

    void saveRoleMapPermission(AuthRole role, Set<AuthPermission> permissions);

    void addRoleMapPermission(AuthRole role, AuthPermission permission);

    /**
     * 根据角色id获取映射
     */
    List<AuthRoleMapPermission> getByRoleId(Long roleId);

    AuthRoleMapPermission getByRoleIdAndPermissionId(Long roleId, Long permissionId);

    Map<Long, AuthRoleMapPermission> getByIds(Set<Long> ids);

    /**
     * 根据角色id获取,返回角色id+':'+权限id作为key
     */
    Map<String, AuthRoleMapPermission> getRIdPIdMapRPByRoleIds(Set<Long> roleIds);
}
